#include "GLIcon.h"
#include "RenderController.h"
#include "common.h"
#include <QApplication>

QVector<QVector3D> GLIcon::getVertices()
{
	QVector<QVector3D> ret;

	auto backSize	= gController->backgroundSize();
	auto windowSize = gController->viewSize() * qApp->devicePixelRatio();
	auto iconSize	= mIconSize;

	auto scale = gController->scale();

	auto windowPos = backgroundPosToWindowPos(mPos, backSize, windowSize, scale);

	auto centerPos = posNormal(windowPos, windowSize);

	qreal iconLength = 2.0 * iconSize.width() / windowSize.width();

	ret << QVector3D(centerPos.x() - iconLength, centerPos.y() - iconLength, 0.0);
	ret << QVector3D(centerPos.x() - iconLength, centerPos.y() + iconLength, 0.0);
	ret << QVector3D(centerPos.x() + iconLength, centerPos.y() + iconLength, 0.0);
	ret << QVector3D(centerPos.x() + iconLength, centerPos.y() - iconLength, 0.0);

	return ret;
}
const QMatrix4x4& GLIcon::compMat() const
{
	return mCompMat;
}
void GLIcon::setCompMat(const QMatrix4x4& mat)
{
	mCompMat = mat;
}
